<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def capacity(self):
 """ Returns the capacity of this Ringbuffer. :return: (long), the capacity of Ringbuffer. """

        if not self._capacity:
            def cache_capacity(f):
                self._capacity = f.result()
                return f.result()

            return self._encode_invoke(ringbuffer_capacity_codec).continue_with(cache_capacity)
        return ImmediateFuture(self._capacity)