UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bpeKNcBjXgCzeyw4BPTu1Z2+hTrEyRLCclpXmRqiBfA=' 
WHERE 
  key_id = '8509dd7c3a325a5b35714a8882afe487264a7a5f9a5f047eed24dd328ae8b377' 
  AND (
    token = 'bpeKNcBjXgCzeyw4BPTu1Z2+hTrEyRLCclpXmRqiBfA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00049