UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TlR9auq3RxJRZcJWPgyjdULVnrP8Z4yF2UGOzXUKdRc=' 
WHERE 
  key_id = '4e2ee70dc6a1a8da71a207bb471600df989795a171e411ce1e34907d0620398d' 
  AND (
    token = 'TlR9auq3RxJRZcJWPgyjdULVnrP8Z4yF2UGOzXUKdRc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025