UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Xd5ama4+aA0IkmmkgCsleach99Ajyz64clXD+xysPnE=' 
WHERE 
  key_id = '2e86c91b9024acb229394048a2697df06e20c886ab74b2bd1cf71a97b433962b' 
  AND (
    token = 'Xd5ama4+aA0IkmmkgCsleach99Ajyz64clXD+xysPnE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031