UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'e8sHRvFpas3pyoBy34yqstUA1CyXJZhSxSOk9+hLmOY=' 
WHERE 
  key_id = 'e2e3f36135082ae1af20c9b1067d3aa75245aff310f766393564dc6effe2aa34' 
  AND (
    token = 'e8sHRvFpas3pyoBy34yqstUA1CyXJZhSxSOk9+hLmOY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032