UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TXmG1vSlpRV0SbvGMutVHJ51qTNtz91GEDr355V+yOA=' 
WHERE 
  key_id = '78dd712a4eb4fd4fbef07e3078623e7bdabd22ad1816e096091ecd2678b9ff20' 
  AND (
    token = 'TXmG1vSlpRV0SbvGMutVHJ51qTNtz91GEDr355V+yOA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031